home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / WCOMDLG.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  7.6 KB  |  259 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WCommonDialog -- Base CommonDialog class
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *       Change --
  19.  *
  20.  *       Close --
  21.  *
  22.  *       CommonDialogPrompt --
  23.  *
  24.  *       Create --
  25.  *
  26.  *       Destroy --
  27.  *
  28.  *       Help --
  29.  *
  30.  *       InitializationDone --
  31.  *
  32.  *       MessageHook --
  33.  *
  34.  *************************************************************************/
  35.  
  36. #ifndef _WCOMDLG_HPP_INCLUDED
  37. #define _WCOMDLG_HPP_INCLUDED
  38. #pragma once
  39.  
  40. #ifndef _WNO_PRAGMA_PUSH
  41. #pragma pack(push,8);
  42. #pragma enum int;
  43. #endif
  44.  
  45. #ifndef _WEVENTD_HPP_INCLUDED
  46. #include "weventd.hpp"
  47. #endif
  48.  
  49. #ifndef _WFILPATH_HPP_INCLUDED
  50. #include "wfilpath.hpp"
  51. #endif
  52.  
  53. #ifndef _WRESID_HPP_INCLUDED
  54. #include "wresid.hpp"
  55. #endif
  56.  
  57. #ifndef _WMODULE_HPP_INCLUDED
  58. #include "wmodule.hpp"
  59. #endif
  60.  
  61. class WWindow;
  62. class WModelessDialog;
  63. class WDialog;
  64. class WModule;
  65.  
  66.  
  67. enum WCommonDialogError {
  68.     // WCommonDialog general errors
  69.     WCDCDErrorNoError           = 0x0000,
  70.     WCDCDErrorGeneralCodes      = 0x0000,
  71.     WCDCDErrorStructSize        = 0x0001,
  72.     WCDCDErrorInitialization    = 0x0002,
  73.     WCDCDErrorNoTemplate        = 0x0003,
  74.     WCDCDErrorNoHINSTANCE       = 0x0004,
  75.     WCDCDErrorLoadStrFailure    = 0x0005,
  76.     WCDCDErrorFindResFailure    = 0x0006,
  77.     WCDCDErrorLoadResFailure    = 0x0007,
  78.     WCDCDErrorLockResFailure    = 0x0008,
  79.     WCDCDErrorMemAllocFailure   = 0x0009,
  80.     WCDCDErrorMemLockFailure    = 0x000A,
  81.     WCDCDErrorNoHook            = 0x000B,
  82.     WCDCDErrorRegisterMsgFail   = 0x000C,
  83.     WCDCDErrorDialogFailure     = 0xFFFF,
  84.  
  85.     // WPrintDialog specific errors
  86.     WCDPDErrorPrinterCodes      = 0x1000,
  87.     WCDPDErrorSetupFailure      = 0x1001,
  88.     WCDPDErrorParseFailure      = 0x1002,
  89.     WCDPDErrorRetDefFailure     = 0x1003,
  90.     WCDPDErrorLoadDrvFailure    = 0x1004,
  91.     WCDPDErrorGetDevModeFail    = 0x1005,
  92.     WCDPDErrorInitFailure       = 0x1006,
  93.     WCDPDErrorNoDevices         = 0x1007,
  94.     WCDPDErrorNoDefaultPrn      = 0x1008,
  95.     WCDPDErrorDNDMMismatch      = 0x1009,
  96.     WCDPDErrorCreateICFailure   = 0x100A,
  97.     WCDPDErrorPrinterNotFound   = 0x100B,
  98.     WCDPDErrorDefaultDifferent  = 0x100C,
  99.  
  100.     // WFontDialog specific errors
  101.     WCDCFErrorChooseFontCodes   = 0x2000,
  102.     WCDCFErrorNoFonts           = 0x2001,
  103.     WCDCFErrorMaxLessThanMin    = 0x2002,
  104.  
  105.     // WFileDialog specific errors
  106.     WCDFNErrorFileNameCodes     = 0x3000,
  107.     WCDFNErrorSubclassFailure   = 0x3001,
  108.     WCDFNErrorInvalidFileName   = 0x3002,
  109.     WCDFNErrorBufferTooSmall    = 0x3003,
  110.  
  111.     // WFindReplaceDialog specific errors
  112.     WCDFRErrorFindReplaceCodes  = 0x4000,
  113.     WCDFRErrorBufferLengthZero  = 0x4001,
  114.  
  115.     // WColorDialog specific errors
  116.     WCDCCErrorChooseColorCodes  = 0x5000,
  117. };
  118.  
  119. struct WNewFileTypeEventData : public WEventData {
  120.     WULong              filterIndex;    // NOTE: 1-based, not 0-based
  121. };
  122.  
  123. struct WSharingViolationEventData : public WEventData {
  124.     WChar *             fileName;
  125. };
  126.  
  127. // The CommonDialogPrompt event occurs immediately before and then
  128. // immediately after a common dialog is displayed.  This allows
  129. // the advanced user to access and modify the raw data structure
  130. // that is passed to the native API common dialog functions.
  131.  
  132. struct WCommonDialogPromptEventData : public WEventData {
  133.     WBool   before;             // if true, event is occurring before prompt
  134.     WDWord  returnedFromPrompt; // value returned from prompt
  135.     void   *promptData;         // pointer to raw data used for prompt
  136. };
  137.  
  138. //
  139. // WCommonDialog
  140. //
  141.  
  142. class WCMCLASS WCommonDialog : public WEventGenerator {
  143.     WDeclareSubclass( WCommonDialog, WEventGenerator );
  144.  
  145.     public:
  146.         WCommonDialog();
  147.  
  148.         ~WCommonDialog();
  149.  
  150.         /********************************************************
  151.          * Properties
  152.          ********************************************************/
  153.  
  154.         // Dialog
  155.         //
  156.         //    Returns a pointer to a WDialog that can be used to
  157.         //    manipulate the common dialog.  For modal dialogs
  158.         //    this property only returns non-NULL when the
  159.         //    dialog is being displayed and thus is typically only
  160.         //    used within events.
  161.  
  162.         WDialog *GetDialog();
  163.  
  164.         // Error
  165.  
  166.         WCommonDialogError GetError() const;
  167.  
  168.         // ModelessDialog
  169.         //
  170.  
  171.         WModelessDialog *GetModelessDialog();
  172.  
  173.         // Owner
  174.         //
  175.         //    Sets/gets the form that owns the dialog.
  176.  
  177.         WWindow *GetOwner() const;
  178.         WBool    SetOwner( WWindow *owner );
  179.  
  180.         // TemplateID
  181.         //
  182.         //    Sets/gets the resource ID that defines the template
  183.         //    to use for the dialog.  0 means no template is used.
  184.  
  185.         WResourceID GetTemplateID() const;
  186.         WBool       SetTemplateID( WResourceID id );
  187.  
  188.         // TemplateModule
  189.         //
  190.         //    Sets/gets the module for the template.  A value of
  191.         //    NULL means use the application module.
  192.  
  193.         WModule GetTemplateModule() const;
  194.         WBool   SetTemplateModule( const WModule & module );
  195.  
  196.         // Title
  197.         //
  198.         //    The title used when displaying the dialog.  The
  199.         //    title may be a null string, in which case a default
  200.         //    value is used.
  201.  
  202.         WString GetTitle() const;
  203.         WBool   SetTitle( const WChar *title );
  204.  
  205.         /********************************************************
  206.          * Methods
  207.          ********************************************************/
  208.  
  209.         // Abort
  210.         //
  211.         //    Causes the dialog to be closed as if the user had
  212.         //    cancelled it.
  213.  
  214.         WBool Abort() const;
  215.  
  216.         /********************************************************
  217.          * Notifications
  218.          ********************************************************/
  219.  
  220.         void OnDialogInitialize( WWindowHandle hWnd, WWindowHandle focus,
  221.                                  WBool modal=TRUE );
  222.         void OnDialogDestroy();
  223.  
  224.         /********************************************************
  225.          * Event handlers
  226.          ********************************************************/
  227.  
  228.         WBool MessageHookEventHandler( WCommonDialog * dialog,
  229.                                        WMessageHookEventData * event );
  230.  
  231.         /********************************************************
  232.          * Data members
  233.          ********************************************************/
  234.  
  235.     protected:
  236.         WWindowHandle    _hWnd;
  237.         WBool            _isModal;
  238.         WDialog         *_dialog;
  239.         WModelessDialog *_modelessDialog;
  240.         WWindow         *_owner;
  241.         WModule          _templateModule;
  242.         WResourceID      _templateID;
  243.         WBool            _hasUserHook;
  244.         WString          _title;
  245.  
  246.     // Internal use only
  247.  
  248.     public:
  249.         WBool HasUserHook() const { return _hasUserHook; }
  250. };
  251.  
  252.  
  253. #ifndef _WNO_PRAGMA_PUSH
  254. #pragma enum pop;
  255. #pragma pack(pop);
  256. #endif
  257.  
  258. #endif // _WCOMDLG_HPP_INCLUDED
  259.